package cn.edu.zjgsu.ito.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.edu.zjgsu.ito.model.ComplainView;
import cn.edu.zjgsu.ito.service.IAdminService;
import cn.edu.zjgsu.ito.util.Constant;
import cn.edu.zjgsu.ito.vo.CapitalVo;

@Controller
@Transactional
@RequestMapping(value="CapitalController")
public class CapitalController
{
	@Autowired
	private IAdminService adminService;

	@RequestMapping(value = "/capital", method = RequestMethod.GET)
	@ResponseBody
	public Map<String, Object> getComplain(
			@RequestParam(name = "sequence", required = false) String sequence)
	{
		Map<String, Object> result = new HashMap<String, Object>();
		int sequenceInt = 0;
		if (sequence != null)
			sequenceInt = Integer.valueOf(sequence);
		List<CapitalVo> ComplainViews = adminService.getMoney(sequenceInt);
		result.put("complains", ComplainViews);
		return success(result);
	}

	private Map<String, Object> error(Map<String, Object> result)
	{
		result.put("code", Constant.FAIL);
		return result;
	}

	private Map<String, Object> success(Map<String, Object> result)
	{
		result.put("code", Constant.OK);
		return result;
	}

}
